/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package stock.utils;

import java.io.File;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;

/**
 *
 * @author peter
 */
public class ExcelFile {

    private Workbook wb = null;
    private Sheet sheet = null;

    public ExcelFile(File file) throws Exception {
        wb = Workbook.getWorkbook(file);
        sheet = wb.getSheet(0);
    }

    public void changeSheet(int i) {
        sheet = wb.getSheet(i);
    }

    /**
     *
     * @param row 行
     * @param col 列
     * @return
     */
    public String get(int row, int col) {
        Cell cell = sheet.getCell(col, row);
        return cell.getContents();
    }

    public int getRows() {
        return sheet.getRows();
    }

    public int getColumns() {
        return sheet.getColumns();
    }

    public void close() {
        wb.close();
    }
}
